package se.webbzon.boltzmann.editor.component.characterlist;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JList;
import javax.swing.ListCellRenderer;

import se.webbzon.boltzmann.editor.list.EditorListCell;
import se.webbzon.boltzmann.game.character.CharacterActionEnum;

public class CharacterListCell extends EditorListCell implements ListCellRenderer<CharacterEntry> {
	
	// Auto generated serial version UID
	private static final long serialVersionUID = -4495680543059411741L;
	
	// The texture entry associated with this list cell
	private CharacterEntry entry;
	
	/*============================================================
	Constructors
	============================================================*/

	public CharacterListCell(Dimension d) {
		super(d);
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	@Override public void paintComponent(Graphics g) {
		super.paintComponent(g);
		g.setFont(getFont());
		g.drawImage(entry.getCharacterTextureSet().getLeftDown(CharacterActionEnum.WALK).get(0).getImage(), 0, 0, 64, 64, this);
		g.drawString(entry.getCharacterTextureSetName(), 80, 32);
	}

	@Override public Component getListCellRendererComponent(
			JList<? extends CharacterEntry> list, 
			CharacterEntry entry, 
			int index, boolean isSelected, boolean cellHasFocus) {
		setSelected(isSelected);
		this.entry = entry;
		return this;
	}

}
